package com.buddies.lottery.ui.home;

import android.widget.TextView;

import com.buddies.lottery.R;
import com.buddies.lottery.data.bean.Lottery;
import com.buddies.lottery.utils.LotteryUtils;
import com.buddies.lottery.widget.CountDownTimerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

public class HomeAdapter extends BaseQuickAdapter<Lottery, BaseViewHolder> {

    public HomeAdapter(List<Lottery> items) {
        super(R.layout.item_home, items);
    }

    @Override
    protected void convert(BaseViewHolder helper, Lottery item) {
        ((SimpleDraweeView) helper.getView(R.id.image)).setImageURI(item.pic_url);

        helper.setText(R.id.text, item.name);

        CountDownTimerView timerView = helper.getView(R.id.timer);
        timerView.bindView(null, (TextView) helper.getView(R.id.status));
        timerView.setTime(item, item.next != null ? item.next.getOpenTimeDelta() : 0);
        timerView.startCountDown();
        timerView.setOnTimerListener(new CountDownTimerView.TimerListener() {
            @Override
            public void onTick(long millisUntilFinished) {

            }

            @Override
            public void onFinish() {
            }
        });
    }

}
